package cn.tedu.charging.device.dao.repository;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class StationCacheFactory {

    /**
     * 读取配置文件
     */
    @Value("${station.warm.dataType}")
    private String dataType;

    @Autowired
    @Qualifier("GeoAndString")
    private StationCacheRepository stationCacheGeoAndStringRepository;


    @Autowired
    @Qualifier("GeoAndGeo")
    private StationCacheRepository stationCacheGeoAndGeoRepository;

    @Autowired
    @Qualifier("GeoAndShareHash")
    private StationCacheRepository stationCacheGeoAndShareHashRepository;


    @Autowired
    @Qualifier("GeoAndNoShareHash")
    private StationCacheRepository stationCacheGeoAndNoHashRepository;




    public StationCacheRepository getStationCacheRepository() {
        if ("GeoAndString".equals(dataType)) { //应该写成常量
            return stationCacheGeoAndStringRepository;
        }else if ("GeoAndGeo".equals(dataType)) { //应该写成常量
            return stationCacheGeoAndGeoRepository;
        }else if ("GeoAndShareHash".equals(dataType)) {
            return stationCacheGeoAndShareHashRepository;
        }else if ("GeoAndNoShareHash".equals(dataType)) {
            return stationCacheGeoAndNoHashRepository;
        }
        return null;
    }
}
